﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using System.ServiceModel;
using services;
using contract1;
using System.ServiceModel.Description;

namespace host
{
    class Program
    {
        static void Main(string[] args)
        {
            using(ServiceHost host=new ServiceHost(typeof(Senor_services)))
            {
                host.AddServiceEndpoint(typeof(ISenor),new WSHttpBinding(),"http://127.0.0.1:3721/Senor_services");
                if(host.Description.Behaviors.Find<ServiceMetadataBehavior>()==null)
                {
                    ServiceMetadataBehavior behavior=new ServiceMetadataBehavior();
                    behavior.HttpGetEnabled=true;
                    behavior.HttpGetUrl=new Uri("http://127.0.0.1:3721/Senor_services/metadata");
                    host.Description.Behaviors.Add(behavior);
                }
                host.Opened+=delegate
                {
                    Console.WriteLine("Senor_services服务已经启动，按任意键终止服务！");
                };
                host.Open();
                Console.Read();
            }
        }
    }
}
